//
//  Quote.h
//  Chart
//
//  Created by caojun on 14/12/8.
//
//

#import "ChartSocketEnum.h"

#import <Foundation/Foundation.h>
#import <Mantle/Mantle.h>
#import "CJQuoteDefine.h"

@interface CJQuote : MTLModel<MTLJSONSerializing>

/** 内码  Ei */
@property(nonatomic, copy) NSString *ID;

/*!
 * 市场ID Exch
 */
@property(nonatomic, copy) NSString *Market;

/*!
 * 市场 ExchNm
 */
@property(nonatomic, copy) NSString *MarketTradingTarget;

/*!
 * 合约代码 Inst
 */
@property(nonatomic, copy) NSString *Inst;

/*!
 * 品种名 InstNm
 */
@property(nonatomic, copy) NSString *AbbrName;

/*!
 * 是否主力合约 0 非主力 其他:主力
 */
@property(nonatomic, strong) NSNumber *IsMain;

/*!
 *  产品类型
 */
@property(nonatomic, assign) CJQuoteType Type;

/*!
 *  交割年份
 */
@property(nonatomic, strong) NSNumber *DeYear;

/** 交割月 */
@property(nonatomic, strong) NSNumber *DeMonth;

/** 限价单最大下单量 */
@property(nonatomic, strong) NSNumber *MaxLiOdVol;

/** 市价单最大下单量 */
@property(nonatomic, strong) NSNumber *MaxMkOdVol;

/** 限价单最小下单量 */
@property(nonatomic, strong) NSNumber *MinLiOdVol;

/** 市价单最小下单量 */
@property(nonatomic, strong) NSNumber *MinMkOdVol;

/** 合约数量乘数 */
@property(nonatomic, strong) NSNumber *VolMul;

/** 多头保证金率 (double) */
@property(nonatomic, strong) NSNumber *LongMaRatio;

/** 低头保证金率 (double) */
@property(nonatomic, strong) NSNumber *ShortMaRatio;

/** 最小变动价位 (double) */
@property(nonatomic, strong) NSNumber *PriTick;

/** 创建日 */
@property(nonatomic, copy) NSString *CrDate;

/** 上市日 */
@property(nonatomic, copy) NSString *OpDate;

/** 到期日 */
@property(nonatomic, copy) NSString *ExDate;

/** 开始交割日 */
@property(nonatomic, copy) NSString *StDeDate;

/** 结束交割日 */
@property(nonatomic, copy) NSString *EdDeDate;

/** 当前是否交易 */
@property(nonatomic, copy) NSNumber *Stat;

@property(nonatomic, assign) CJPosType PosType;


@property(nonatomic, assign) CJPosDateType PosDateType;

/** 交易时段 */
@property(nonatomic, copy) NSString *TradeTimes;

/** 交易时间段( 与交易日关联，精确到time_t) */
@property(nonatomic, copy) NSString *TradeTimeTs;

/** 交易日 */
@property(nonatomic, copy) NSString * TrdDy;

/**-----------------------------------以下是快照数据-------------------------------------------------*/


/** 快照更新时间 */
@property(nonatomic, strong) NSNumber *UpdTm;

/** 最后修改毫秒 */
@property(nonatomic, strong) NSNumber *UpdTmSec;

/** 成交量 */
@property(nonatomic, strong) NSNumber *Vol;

/** 成交额 */
@property(nonatomic, strong) NSNumber *Tuov;

/*!
 * (double) 均价 AvPri
 */
@property(nonatomic, strong) NSNumber *AvgPx;

/*!
 * (double) 开盘 OpPri
 */
@property(nonatomic, strong) NSNumber *OpenPx;

/*!
 * (double) 最高 HiPri
 */
@property(nonatomic, strong) NSNumber *HighPx;

/*!
 * (double) 最低 LoPri
 */
@property(nonatomic, strong) NSNumber *LowPx;

/*!
 * (double) 最新价 LsPri
 */
@property(nonatomic, strong) NSNumber *LatestPx;

/*!
 * (double) 昨收 PreClPri
 */
@property(nonatomic, strong) NSNumber *PrevClosePx;

/*!
 * (double) 今收盘价 ClPri
 */
@property(nonatomic, strong) NSNumber *ClPx;

/*!
 * (double) 昨结
 */
@property(nonatomic, strong) NSNumber *PreSePri;

/*!
 * (double) 本次结算价
 */
@property(nonatomic, strong) NSNumber *SePri;

/*!
 * (double)
 */
@property(nonatomic, strong) NSNumber *AskPx1;

/*!
 * (double)
 */
@property(nonatomic, strong) NSNumber *AskPx2;

/*!
 * (double)
 */
@property(nonatomic, strong) NSNumber *AskPx3;

/*!
 * (double)
 */
@property(nonatomic, strong) NSNumber *AskPx4;

/*!
 * (double)
 */
@property(nonatomic, strong) NSNumber *AskPx5;

/*!
 * (double)
 */
@property(nonatomic, strong) NSNumber *AskVolume1;

/*!
 * (double)
 */
@property(nonatomic, strong) NSNumber *AskVolume2;

/*!
 * (double)
 */
@property(nonatomic, strong) NSNumber *AskVolume3;

/*!
 * (double)
 */
@property(nonatomic, strong) NSNumber *AskVolume4;

/*!
 * (double)
 */
@property(nonatomic, strong) NSNumber *AskVolume5;

/*!
 * (double)
 */
@property(nonatomic, strong) NSNumber *BidPx1;

/*!
 * (double)
 */
@property(nonatomic, strong) NSNumber *BidPx2;

/*!
 * (double)
 */
@property(nonatomic, strong) NSNumber *BidPx3;

/*!
 * (double)
 */
@property(nonatomic, strong) NSNumber *BidPx4;

/*!
 * (double)
 */
@property(nonatomic, strong) NSNumber *BidPx5;

/*!
 * (double)
 */
@property(nonatomic, strong) NSNumber *BidVolume1;

/*!
 * (double)
 */
@property(nonatomic, strong) NSNumber *BidVolume2;

/*!
 * (double)
 */
@property(nonatomic, strong) NSNumber *BidVolume3;

/*!
 * (double)
 */
@property(nonatomic, strong) NSNumber *BidVolume4;

/*!
 * (double)
 */
@property(nonatomic, strong) NSNumber *BidVolume5;

/*!
 * (double) 今虚实度
 */
@property(nonatomic, strong) NSNumber *CurrDelta;

/*!
 * 昨虚实度
 */
@property(nonatomic, strong) NSNumber *PreDelta;

/** 涨停板价 */
@property(nonatomic, strong) NSNumber *UpLiPrice;

/** 跌停板价 */
@property(nonatomic, strong) NSNumber *LoLiPrice;

/** 昨持仓量 */
@property(nonatomic, strong) NSNumber *PreOpInt;

/** 持仓量 */
@property(nonatomic, strong) NSNumber *OpInt;


/*!
 * (double) 涨跌
 */
@property(nonatomic, strong) NSNumber *UpDropPx;

/*!
 * (double) 涨幅
 */
@property(nonatomic, strong) NSNumber *PercentPx;

/*!
 * (double) 委差 Bid1 - Adk1
 */
@property(nonatomic, strong) NSNumber *CommitteeDiffPx;


/*!
 * (double) 委比 CommitteeDiffPx / (Bid1 + Ask1)
 */
@property(nonatomic, strong) NSNumber *CommitteePercentPx;

/** 是否有效 */
- (BOOL)isValidID;

/** 根据字典生成一个新的Securities */
+ (CJQuote *)quoteWithDictionary: (NSDictionary *)dictionary;

/** 更新当前值变化 */
- (void)updateWithQuote: (CJQuote *)quote;


/**************************************************************************************************/














@property(nonatomic, copy) NSString *AskSettlType;

/*!
 * 重量单位
 */
@property(nonatomic, copy) NSString *BidQuoteSide;

/*!
 * 交易时间
 */
@property(nonatomic, copy) NSString *BondCategory;

/*!
 * (int)
 */
@property(nonatomic, strong) NSNumber *InternalCode;

@property(nonatomic, copy) NSString *Keywords;





/*!
 * (int) 保留几位小数
 */
@property(nonatomic, strong) NSNumber *MinuteSpan;

/*!
 * (int) OffSet>1 有成交量
 */
@property(nonatomic, strong) NSNumber *OffSet;

/*!
 * 价格单位（如：人民币）
 */
@property(nonatomic, copy) NSString *OfferQuoteSide;

/*!
 * (double) 昨结算
 */
@property(nonatomic, strong) NSNumber *PreSettlementPx;



/*!
 * 权限 "ReserveString_1" = 020100010201020100010201;
 * TT TD YG TouristTT TouristTD TouristYG SSY TouristSSY BSY BSYTourist
 */
@property(nonatomic, copy) NSString *ReserveString_1;

/*!
 * 交易单位 一手为多少单位，默认一手为一单位（Unit=1）
 */
@property(nonatomic, strong) NSNumber *Unit;

/*!
 * 品种id 不是唯一
 */
@property(nonatomic, copy, readonly) NSString *SecurityID;

@property(nonatomic, copy) NSString *SecurityType;

/*!
 * (uint) 昨收 都使用昨收
 */
@property(nonatomic, strong) NSNumber *Sequence;

@property(nonatomic, copy) NSString *StringField;






/*!
 * (double)
 */
@property(nonatomic, strong) NSNumber *PreOpenPosition;

/*!
 * (long)
 */
@property(nonatomic, strong) NSNumber *DateTime;



/*!
 * (double) 振幅
 */
@property(nonatomic, strong) NSNumber *AmplitudePx;


/*--------------以下是上海金才有数据的字段---------------------*/

/*!
 * (double) 总成交额
 */
@property(nonatomic, strong) NSNumber *TotalTradeAmount;

/*!
 * (double) 总成交量
 */
@property(nonatomic, strong) NSNumber *TotalTradeVolume;

/*!
 * (double) 现手
 */
@property(nonatomic, strong) NSNumber *TradeVolume;





/*---------------------------------------------------------------------------*/






/*!
 * 有无成交量 不能监听
 */
@property(nonatomic, assign) BOOL HasVolume;

/*!
 * (int) 默认 的保留几位小数
 */
@property(nonatomic, strong) NSNumber *defaultMinuteSpan;

/*!
 * (int) 默认的 OffSet>1 有成交量
 */
@property(nonatomic, strong) NSNumber *defaultOffSet;


- (id)init;

- (void)setIDWithSecurityID:(NSString *)SecurityID
                 withMarket:(NSString *)Market;

- (NSDictionary *) toDictionary;



- (void)updateWithDictionary: (NSDictionary *)dictonary;



//int TT TD YG TouristTT TouristTD TouristYG SSY TouristSSY BSY BSYTourist
- (NSNumber *)getClientTagWidthServerId:(YTXServerId )serverId
                 withIsLogin:(BOOL)isLogin;



+ (NSDictionary *)generateChartViewDictFromQuote:(CJQuote *)quote;

@end
